package cn.iocoder.yudao.adminserver.franky.LRU;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @Description: 双重检测
 * @Author: franky
 * @CreateDate: 2021/4/19 1:27 下午
 * @Version: 1.0
 */
public class Singleton3 {
    public static Singleton3 instance;
    public AtomicLong atomicLong = new AtomicLong(0);

    private Singleton3() {}

    public static Singleton3 getInstance() {
        if (null == instance) {
            synchronized (Singleton3.class) {
                if (null == instance) {
                    instance = new Singleton3();
                }
            }
        }
        return instance;
    }

    public long getId() {
        return atomicLong.incrementAndGet();
    }
}
